﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <div>
    <el-form ref="formRefOperation" :model="stateOperation.vmModel" label-width="100px">
      <el-row>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_LineCodeId_FormItem" prop="Entity.LineCodeId" :label="$t('message.autotrans._Model_Operation_LineCode')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_Operation_LineCode')}), trigger: 'blur' }]" >
            <el-select v-model="stateOperation.vmModel.Entity.LineCodeId" filterable clearable>
               <el-option v-for="item in stateOperation.AllLineCodes" :key="item.Value" :value="item.Value" :label="item.Text"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_OperationId_FormItem" prop="Entity.OperationId" :label="$t('message.autotrans._Model_Operation_OperationId')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_Operation_OperationId')}), trigger: 'blur' }]" >
            <el-input v-model="stateOperation.vmModel.Entity.OperationId" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_OperationName_FormItem" prop="Entity.OperationName" :label="$t('message.autotrans._Model_Operation_OperationName')">
            <el-input v-model="stateOperation.vmModel.Entity.OperationName" clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

      <div style="text-align:right;">
        <WtmButton @click="onSubmitOperation"  type="primary" :button-text="$t('message.autotrans.SysSubmit')" style="margin-top:15px;"/>

        <WtmButton @click="onCloseOperation"  type="primary" :button-text="$t('message.autotrans.SysClose')" style="margin-top:15px;"/>

      </div>

    </el-form>

  </div>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageBaseInformationOperationCreate;false">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { operationApi } from '/@/api/baseinformation/operation';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;


// 定义变量内容
const formRefOperation = ref();
const stateOperation = reactive({
    vmModel: {
	  Entity:{
        LineCodeId: null,
        OperationId: '',
        OperationName: '',
      },

	},
    
    AllLineCodes: [] as any[],
});

// 取消
const onCloseOperation = () => {
    closeDialog();
};

// 提交
const onSubmitOperation = () => {
 	const loadingInstance = ElLoading.service({
		lock: true,
		text: '正在提交中，请等待。。。',
		background: 'rgba(0, 0, 0, 0.7)',
	});
   formRefOperation.value?.validate((valid: boolean, fields: any) => {
		if (valid) {
            operationApi().add(stateOperation.vmModel).then(() => {
                ElMessage.success(ci.proxy.$t('message._system.common.vm.submittip'));
                emit('refresh');
                closeDialog();
            }).catch((error) => {
                other.setFormError(ci, error);
            }).finally(() => {
			loadingInstance.close();
		    })
		}
	})
};

// 页面加载时
onMounted(() => {
    
    other.getSelectList('/api/BaseInformation/Operation/GetLines',[],false).then(x=>{stateOperation.AllLineCodes = x});
});

// 定义子组件向父组件传值/事件
const emit = defineEmits(['refresh','closeDialog']);
// 关闭弹窗
const closeDialog = () => {
    emit('closeDialog');
};
// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

